<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="zh-cn">
    <head>
        <!-- Bootstrap -->
        <include file="Include/css" />
        <title></title>
        <link href="__STATICS__/css/admin/index.css" rel="stylesheet">
        <link href="__STATICS__/css/sweet-alert.css" rel="stylesheet">
        <script type="text/javascript" src="__STATICS__/js/sweet-alert.min.js"></script>
    </head>

    <body>
        <include file="Include/nav_top" />
        <div class="container clearfix" id="left_menu_wraper" >
            <include  file="Include/menu_left" />
            <div id="right-content">
                <div id="right-content-inner">
                    <ul class="breadcrumb">
                        <span>您的位置：</span>
                        <li><a href="{:U('Houtai/Index/index')}">首页</a> </li>
                        <li class="">商品管理</li>
                        <li class="active">商品类型</li>
                    </ul>
                    <p>
                        <button id="add_look" class="btn btn-orange" type="button" >
                            添加类型
                        </button>
                    </p>
                    <div role="tabpanel">
                        <div class="row clearfix margin10 form-horizontal">
                            <form  name="query" >
                                <span class="pull-left ml30 form_bar">查询：</span>
                                <div class="col-md-2">
                                    <input type="text" name="sCatName" value="{$Think.request.sCatName}" placeholder=" 名称" class="pull-left ml10 form-control" />
                                </div>
                                <div class="col-md-2">
                                    <select  name="sCommentType" class="pull-left ml10 form-control" >
                                            <option value="-1" <eq name="Think.request.sCommentType" value="-1" > selected </eq> >-类型-</option>
                                            <option value="1" <eq name="Think.request.sCommentType" value="1" > selected </eq> >附属商品类型</option>
                                            <option value="0" <eq name="Think.request.sCommentType" value="0" > selected </eq> >增值商品类型</option>
                                    </select>
                                </div>
                                <button type="submit" class="pull-left btn btn-default ml20">搜索</button>
                            </form>
                        </div>
                                <table class="table ">
                                    <thead class="table_head">
                                        <tr class="border">
                                            <th>编号</th>
                                            <th>名称</th>
											<th>所属商城</th>
                                            <th>预下单编码</th>
                                            <th>类型</th>
                                            <th>添加时间</th>
                                            <th>操作</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <volist name="list" id="vo">
                                            <tr class="qr_tar" >
                                                <td  >
                                                    {$i+$num}
                                                </td>
                                                <td >
                                                {$vo.catName}
                                                </td>
												<td >
                                                <eq name="vo.shop" value="1" > 
														折扣商城
                                                	<else />
                                                		汽车美容商城
                                                	</eq>
                                                </td>
                                                <td >
                                                {$vo.code}
                                                </td>
                                                <td >
                                                	<eq name="vo.commentType" value="1" > 
														<font color="orange">附属商品类型</font>
                                                	<else />
                                                		增值商品类型
                                                	</eq>
                                                </td>
                                                <td>{$vo['addTime'] | date="Y/m/d H:i:s",###} </td>
                                                <td data-id="{$vo.catID}" data-name="{$vo.catName}" data-shop="{$vo.shop}"
                                                    data-code="{$vo.code}" 
                                                data-type="{$vo.commentType}" 
                                                data-time="{$vo['addTime'] | date="Y/m/d H:i:s",###}" >
                                                    <a href="javascript:void(0);" class="edit_look" >编辑</a>
                                                    /
                                                    <a href="javascript:void(0);" class="tar_delete" >删除</a>
                                                </td>
                                            </tr>
                                        </volist>
                                    </tbody>
                                </table>

                                <div class="clearfix s_page pull-right">
                                    {$page}
                                </div>
                            </div>

                    </div>

                </div>

            </div>
        
        <!-- 任务基本信息 Modal - 开始 -->
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog modal-lg">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                        <h4 class="modal-title" id="myModalLabel"> </h4>
                    </div>
                    <div class="modal-body">
                        <div role="tabpanel" class="tab-pane active" id="home">

                            <div class="row clearfix">
                                <div class="col-md-12 margin10">
                                    <div class="col-md-2 text_right form_bar">
                                                    	名称：
                                    </div>
                                    <div class="col-md-4">
                                            <input id="catName" type="text" class="form-control"/>
                                    </div>
                                    <div class="col-md-6 text_warning text_left form_bar">
                                                    * 
                                    </div>
                                </div>
                                
                            </div>
							<div class="row clearfix">
                                <div class="col-md-12 margin10">
                                    <div class="col-md-2 text_right form_bar">
                                                    	所属商城：
                                    </div>
                                    <div class="col-md-4">
                                            <select class="form-control" id="shop">
                                            	<option value="1">折扣商城</option>
                                            	<option value="2">汽车美容商城</option>
                                            </select>
                                    </div>
                                    <div class="col-md-6 text_warning text_left form_bar">
                                                    * 
                                    </div>
                                </div>
                                
                            </div>
                            <div class="row clearfix">
                                <div class="col-md-12 margin10">
                                    <div class="col-md-2 text_right form_bar">
                                                    	类型：
                                    </div>
                                    <div class="col-md-4">
                                            <select class="form-control" id="commentType">
                                            	<option value="0">增值商品类型</option>
                                            	<option value="1">附属商品类型</option>
                                            </select>
                                    </div>
                                    <div class="col-md-6 text_warning text_left form_bar">
                                                    * 
                                    </div>
                                </div>
                                
                            </div>
                            <div class="row clearfix" >
                                <div class="col-md-12 margin10">
                                    <div class="col-md-2 text_right form_bar">
                                                    	预下单编码：
                                    </div>
                                    <div class="col-md-4">
                                        <input id="code" type="text" class="form-control" />
                                    </div>
                                    <div class="col-md-6 text_warning text_left form_bar">
                                                    填写则进行预下单操作
                                    </div>
                                </div>
                                
                            </div>
                            
                             <input type="hidden" id="catID" />
                        </div>

                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                        <button type="button" class="btn btn-primary" id="save" >保存</button>
                    </div>
                </div>
            </div>
        </div><!-- 任务基本信息 Modal - 结束 -->
                
        <include file="Include/script" />
        <script src="__STATICS__/js/bootstrap-editable.min.js"></script>

       <script>
            var isReload = false; // 标识弹出框关闭之后是否刷新页面
            var myDom; // 当前操作的dom对象
            var img_url="__STATICS__/images";
            
                function onSave(rsp) {
                    if(rsp.result > 0) {
                        swal("操作成功","","success");
                        window.location.reload();
                    } else {
                        swal("操作失败;"+rsp.desc,"","error");
                    }
                }
                
                /*清空弹出框内容*/
                function reset_display()
                {
                    $("#catID").val("");
                    $("#catName").val("");
                    $("#code").val("");
                    //$("#code").attr("disabled",true);
                                        
                }
                 
                function onDel(rsp) {
                    if(rsp.result > 0) {
                        window.location.reload();
                    } else {
                        swal("操作失败",'',"error");
                    }
                }
                
            /*菜单展开及高亮*/
            $(function () {
                $('.goods').addClass('open');
                $('#goods2').addClass('active');

                /*基本信息的弹出框隐藏后*/
                $('#myModal').on('hidden.bs.modal', function (e) {
                     reset_display();
                });
                
                /*编辑*/
                $(".edit_look").on("click", function () {
                    var self = $(this);
                    var catID = self.closest("td").attr("data-id");
                    var catName = self.closest("td").attr("data-name");
                    var code = self.closest("td").attr("data-code");
                    var type = self.closest("td").attr("data-type");
                    var addTime = self.closest("td").attr("data-time");
                    var shop = self.closest("td").attr("data-shop");
                    $("#catID").val(catID);
                    $("#catName").val(catName);
					
                    $("#code").val(code);
                    $("#commentType").val(type);
                    $("#shop").val(shop);
                    /* if(type > 0) {
                        $("#code").attr("disabled",false);
                    } else {
                        $("#code").attr("disabled",true);
                    } */
                    
                    $("#myModalLabel").html("编辑(添加时间:"+addTime+")");
                    $('#myModal').modal(); // 跳出弹窗

                });
                
                /*删除弹窗*/
                $(".tar_delete").on("click", function () {
                    var self = $(this);
                    swal({   title: "您确定吗?",
                                text: "您将删除此类型！",
                                type: "warning",
                                showCancelButton: true,
                                confirmButtonColor: "#DD6B55",
                                confirmButtonText: "是的，删除",
                                cancelButtonText: "放弃",
                                closeOnConfirm: false
                            },
                            function (isConfirm) {
                                if (isConfirm) {
                                    var ajaxData = {};
                                    ajaxData.catID = self.closest('td').attr('data-id');
                                    ajax_go_1(ajaxData , "{:U('CNEPAdmin/GoodsCat/deleteGoodsCat')}", onDel);
                                }

                            });
                });
               
                /*添加时候弹窗*/
                $("#add_look").on("click", function() {
                    $("#myModalLabel").html("添加商品类型");
                    $('#myModal').modal(); // 跳出弹窗
                });
                
                /*点击保存*/
                $("#save").on("click", function () {
                    var rt = true;
                                        
                    var catName = $.trim($("#catName").val());
                    var code = $.trim($("#code").val());
                    var catID = $("#catID").val();
                    
                    if(catName === '')
                    {   
                        rt = false;
                        $('#catName').focus();
                        swal('名称不能为空','','warning');
                    }
                    
                    if(rt) {
                        var ajaxData ={};
                        ajaxData.catName = catName;
                        ajaxData.commentType = $("#commentType").val();
                        ajaxData.shop = $("#shop").val();
                        ajaxData.code = code;
                        if(catID > 0) ajaxData.catID = catID;
                        
                         ajax_go_1(ajaxData ,"{:U('CNEPAdmin/GoodsCat/saveGoodsCat')}",onSave);
                    } else {
                        return rt;
                    }
                    
                });
                
                /* $("#commentType").on('change',function() {
                    if($(this).val() > 0) {
                        $("#code").attr('disabled',true);
                    } else {
                        $("#code").attr('disabled',true);
                    }
                }); */
                

            });
                        
        </script>
    </body>
</html>